<?php
/**
 * 功能： db类入口
 * 说明：
 * 创建日期：
 * 更新日期：
 * 作者：Mirze
 * 补充说明： 
 * 
 */

class Db
{	
	/**  **/
	public function __construct()
	{		
	}

	public static function factory($adapter = 'mysql', $config = array())
    {
		if (!is_string($adapter) || empty($adapter)) {
            throw new throw_exception('Adapter name must be specified in a string');
        }

		$adapterName = strtolower($adapter);
		if (!class_exists($adapterName)) {
            require_once(LIB_DIR . '/core/db/' . $adapterName . '.php');
        }
		$dbAdapter = new $adapterName($config);

		 if (! $dbAdapter instanceof db_abstract) {
            throw new throw_exception("Adapter class '$adapterName' does not extend Db_Abstract");
        }

		return $dbAdapter;
	}

	function test()
	{
         throw new throw_exception("Adapter class '' does not extend test");		
	}


	/**  析构函数 **/
	function __destruct()
	{		
	}
}
?>